commonlibsse_ng\re\b/
BSTCaseInsensitiveStringMap.rs1use std::hash::{Hash, Hasher};
7
8use crate::re::NiTStringMap::NiTStringMap;
9
10#[repr(C)]
12#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
13pub struct BSTCaseInsensitiveStringMap<V> {
14 pub __base: NiTStringMap<V>,
15}
16
17const _: () = {
18 type ParentType = [u8; 0x20];
19 assert!(core::mem::offset_of!(BSTCaseInsensitiveStringMap::<ParentType>, __base) == 0x00);
20 assert!(core::mem::size_of::<BSTCaseInsensitiveStringMap::<ParentType>>() == 0x28);
21};
22
23pub trait BSTCaseInsensitiveStringMapTrait<T> {
25 fn hash_function(&self, key: &str) -> u32;
33
34 fn key_eq(&self, lhs: &str, rhs: &str) -> bool;
43}
44
45impl<T> BSTCaseInsensitiveStringMapTrait<T> for BSTCaseInsensitiveStringMap<T> {
46 #[inline]
47 fn hash_function(&self, key: &str) -> u32 {
48 let mut hasher = std::collections::hash_map::DefaultHasher::new();
50 key.to_lowercase().hash(&mut hasher);
51 hasher.finish() as u32
52 }
53
54 #[inline]
55 fn key_eq(&self, lhs: &str, rhs: &str) -> bool {
56 lhs.eq_ignore_ascii_case(rhs)
57 }
58}
59
60#[repr(C)]
64pub struct BSTCaseInsensitiveStringMapVtbl<T> {
65 pub CxxDrop: fn(this: &mut BSTCaseInsensitiveStringMap<T>),
67
68 pub HashFunction: fn(this: &BSTCaseInsensitiveStringMap<T>, key: &str) -> u32,
70
71 pub KeyEq: fn(this: &BSTCaseInsensitiveStringMap<T>, lhs: &str, rhs: &str) -> bool,
73}